<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客注册页</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/login.css">
</head>

<body>
<!-- 导航栏 -->
<div class="nav">
    <img src="../image/logo2.jpg" alt="">
    <div class="title">我的博客系统</div>
    <div class="spacer"></div>
    <a href="blog_list.jsp">主页</a>
    <a href="blog_edit.jsp">写博客</a>
</div>

<!-- 注册页的版心 -->
<div class="login-container">
    <div class="login-dialog2">
        <h3>注册</h3>
        <form action="/blog/register" method="post" id="registerForm">
            <div class="row">
                <span>用户名</span>
                <input type="text" id="username" name="username" required>
            </div>
            <div class="row">
                <span>密码</span>
                <input type="password" id="password" name="password" required>
            </div>
            <div class="row">
                <span>确认密码</span>
                <input type="password" id="confirm-password" name="confirm-password" required>
            </div>

            <!-- 验证码输入框 -->
            <div class="row">
                <span>验证码</span>
                <input type="text" id="inputCaptcha" name="inputCaptcha" required placeholder="请输入验证码">
                <!-- 验证码图片 -->
                <img id="verificationCodeImg" src="<%= request.getAttribute("captchaImageUrl") != null ? request.getAttribute("captchaImageUrl") : "http://localhost:8080/blog/kaptcha.jpg" %>"
                     style="width: 100px; height: 28px;" alt="验证码" />
            </div>

            <div class="row">
                <input type="submit" id="submit" value="注册">
            </div>
        </form>
        <div class="row">
            <a href="login.jsp">
                <input type="button" id="login-btn" class="register-btn" value="返回登录">
            </a>
        </div>
    </div>
</div>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>
    $(function () {
        // 点击验证码图片时刷新验证码
        $("#verificationCodeImg").click(function () {
            $(this).hide().attr('src', '/blog/kaptcha.jpg?' + new Date().getTime()).fadeIn();
        });
    })
</script>
</body>

</html>
